n = int(input())
array = []
for _ in range(n):
    array.append(int(input()))
prefix = [0] * n
for i in range(n):
    if i:
        prefix[i] = prefix[i-1]
    prefix[i] += array[i]

def sumOf(l,r):
    if l:
        return prefix[r] - prefix[l-1]
    return prefix[r]
while True:
    try:
        innn = tuple(map(int,input().split()))
    except Exception as e:
        break
    if len(innn)<=1: 
        break
    l,r = innn
    print(sumOf(l,r))
    